<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'email-list-form',
    'enableAjaxValidation'=>false,
)); ?>

<p class="note"><?php echo Yii::t('site','Fields with {marker} are required.',array('{marker}'=>'<span class="required">*</span>')); ?></p>

    <?php echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model,'name'); ?>
        <?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>255)); ?>
        <?php echo $form->error($model,'name'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'description'); ?>
        <?php echo $form->textArea($model,'description',array('rows'=>6, 'cols'=>50)); ?>
        <?php echo $form->error($model,'description'); ?>
    </div>

<table>
    <thead>
        <tr><th>Type</th><th>Name</th><th>Email</th><th>Delete</th></tr>
    </thead>
    <tbody>
        <?php if(is_array($emailListItems)) : ?>
        <?php foreach($emailListItems as $i=>$item): ?>
        <tr class="<?php echo $i%2 ? 'even' : 'odd'; ?>">
            <td><?php echo CHtml::activeHiddenField($item,"[$i]id"); ?><?php echo CHtml::activeDropDownList($item,"[$i]recipientType",EmailListItem::model()->recipientTypeOptions); ?></td>
            <td><?php echo CHtml::activeTextField($item,"[$i]recipientName"); ?></td>
            <td><?php echo CHtml::activeTextField($item,"[$i]recipientEmail",array('size'=>40)); ?></td>
            <td><?php if($item->id<>'') : ?><input type="checkbox" name="EmailListItem[<?php echo $i ?>][delete]" value="1" /><?php endif; ?></td>
        </tr>
        <?php endforeach; ?>
        <?php else : $i=0; ?>
        <?php endif; ?>
        <tr>
            <td><?php //echo CHtml::activeTextField($item,"[$i]recipientType"); ?></td>
            <td><?php //echo CHtml::activeTextField($item,"[$i]recipientName"); ?></td>
            <td><?php //echo CHtml::activeTextField($item,"[$i]recipientEmail"); ?></td>
        </tr>
    </tbody>
</table>

    <div class="row buttons">
        <?php $this->widget( 'application.extensions.button.DDButton',
			array(
				'title'=>$model->isNewRecord?Yii::t('site','Create'):Yii::t('site','Save'),
				'linkTitle'=>$model->isNewRecord?Yii::t('site','Create this record'):Yii::t('site','Save this record'),
				'formID' => 'email-list-form',
				'buttonType' => 'save'
		)); ?>
        <?php $this->widget( 'application.extensions.button.DDButton',
			array(
				'title'=>Yii::t('site','Reset'),
				'linkTitle'=>Yii::t('site','Reset the form data'),
				'formID' => 'email-list-form',
				'buttonType' => 'reset',
				'confirm' => Yii::t('site','Really reset this form?')
		)); ?>
        <?php $this->widget( 'application.extensions.button.DDButton',
			array(
				'title'=>Yii::t('site','Cancel'),
				'linkTitle'=>Yii::t('site','Cancel editing, back to list'),
				'formID' => 'email-list-form',
				'buttonType' => 'cancel',
				'confirm' => Yii::t('site','Really cancel editing this item?'),
				'url' => array('emaillist/index')
		)); ?>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->
